package router

import (
	"go_web/api"
	"go_web/views"
	"net/http"
)

func Router() {
	//1.页面HTML 2.数据API 3.静态资源
	http.HandleFunc("/", views.HTML.Index)
	//http://localhost:8080/c/1
	http.HandleFunc("/c/", views.HTML.Category)
	//http://localhost:8080/p/1.html
	http.HandleFunc("/p/", views.HTML.ArticleDetail)
	http.HandleFunc("/writing", views.HTML.Writing)
	http.HandleFunc("/pigeonhole", views.HTML.Pigeonhole)
	//登录
	http.HandleFunc("/login", views.HTML.Login)

	http.HandleFunc("/api/v1/login", api.API.Login)
	http.HandleFunc("/api/v1/post", api.API.SaveAndUpdatePost)
	http.HandleFunc("/api/v1/post/", api.API.GetPost)
	http.HandleFunc("/api/v1/post/search", api.API.SearchPost)
	http.HandleFunc("/api/v1/qiniu/token", api.API.QiniuToken)

	http.Handle("/resource/", http.StripPrefix("/resource/", http.FileServer(http.Dir("public/resource/"))))
}
